﻿namespace Smart.ERP
{
    using DevExpress.XtraEditors;
    using Smart.Data.Helper;
    using Smart.Utils.Lib;
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Windows.Forms;

    public class INVENTORYS
    {
        private double m_Amount;
        private string m_Bacth;
        private string m_Currency_ID;
        private string m_Customer_ID;
        private double m_ExchangeRate;
        private long m_ID;
        private int m_Lock;
        private string m_Product_ID;
        private string m_ProductName;
        private double m_Quantity;
        private DateTime m_Stock_Date;
        private string m_Stock_ID;
        private double m_UnitPrice;

        public INVENTORYS()
        {
            this.m_ID = 0L;
            this.m_Stock_Date = DateTime.Now;
            this.m_Stock_ID = "";
            this.m_Product_ID = "";
            this.m_ProductName = "";
            this.m_Customer_ID = "";
            this.m_Currency_ID = "";
            this.m_Quantity = 0.0;
            this.m_ExchangeRate = 0.0;
            this.m_UnitPrice = 0.0;
            this.m_Amount = 0.0;
            this.m_Bacth = "";
            this.m_Lock = 0;
        }

        public INVENTORYS(long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            this.m_ID = ID;
            this.m_Stock_Date = Stock_Date;
            this.m_Stock_ID = Stock_ID;
            this.m_Product_ID = Product_ID;
            this.m_ProductName = ProductName;
            this.m_Customer_ID = Customer_ID;
            this.m_Currency_ID = Currency_ID;
            this.m_Quantity = Quantity;
            this.m_ExchangeRate = ExchangeRate;
            this.m_UnitPrice = UnitPrice;
            this.m_Amount = Amount;
            this.m_Bacth = Bacth;
            this.m_Lock = Lock;
        }

        public void AddCombo(System.Windows.Forms.ComboBox combo)
        {
            MyLib.TableToComboBox(combo, this.GetList(), "INVENTORYName", "INVENTORYID");
        }

        public void AddComboAll(System.Windows.Forms.ComboBox combo)
        {
            DataTable list = new DataTable();
            list = this.GetList();
            DataRow row = list.NewRow();
            row["INVENTORYID"] = "All";
            row["INVENTORYName"] = "Tất cả";
            list.Rows.InsertAt(row, 0);
            MyLib.TableToComboBox(combo, list, "INVENTORYName", "INVENTORYID");
        }

        public DataTable Adjustment(string Stock_ID, string Product_Id, string productName, DateTime dateTime)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id", "@ProductName", "@Date" };
            object[] myValues = new object[] { Stock_ID, "%" + Product_Id + "%", "%" + productName + "%", dateTime };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_GetList_Adjustment", myParams, myValues);
        }

        public DataTable AdjustReportDate(DateTime FromDate, DateTime ToDate, string Stock, string Product)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@StockID", "@ProductID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock, Product };
            return helper.ExecuteDataTable("ADJUSTMENT_DETAIL_ReportDate", myParams, myValues);
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { this.m_ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_Delete", myParams, myValues);
        }

        public string Delete(long ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, long ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "INVENTORY_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, long ID)
        {
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_Delete", myParams, myValues);
        }

        public DataTable Detail(string Stock_ID, string Product_Id)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id" };
            object[] myValues = new object[] { Stock_ID, Product_Id };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_DETAILREPORT", myParams, myValues);
        }

        public DataTable DetailOverLimit(string Stock_ID, string Product_Id, DateTime m_Now)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id", "@Now" };
            object[] myValues = new object[] { Stock_ID, Product_Id, m_Now };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_DETAIL_ORVERLIMIT_REPORT", myParams, myValues);
        }

        public DataTable DetailOverStored(string Stock_ID, string Product_Id, DateTime m_Now)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id", "@Now" };
            object[] myValues = new object[] { Stock_ID, Product_Id, m_Now };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_DETAIL_OLDSTORED_REPORT", myParams, myValues);
        }

        private void DispError(object sender, SqlHelperException e)
        {
            XtraMessageBox.Show(e.Message, "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public bool Exist(long ID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("INVENTORY_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(long ID)
        {
            string str = "";
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("INVENTORY_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ID = Convert.ToInt64(reader["ID"]);
                    this.m_Stock_Date = Convert.ToDateTime(reader["Stock_Date"]);
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_ProductName = Convert.ToString(reader["ProductName"]);
                    this.m_Customer_ID = Convert.ToString(reader["Customer_ID"]);
                    this.m_Currency_ID = Convert.ToString(reader["Currency_ID"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle(reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_Bacth = Convert.ToString(reader["Batch"]);
                    this.m_Lock = Convert.ToInt32(reader["Lock"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, long ID)
        {
            string str = "";
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "INVENTORY_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ID = Convert.ToInt64(reader["ID"]);
                    this.m_Stock_Date = Convert.ToDateTime(reader["Stock_Date"]);
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_ProductName = Convert.ToString(reader["ProductName"]);
                    this.m_Customer_ID = Convert.ToString(reader["Customer_ID"]);
                    this.m_Currency_ID = Convert.ToString(reader["Currency_ID"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle(reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_Bacth = Convert.ToString(reader["Bacth"]);
                    this.m_Lock = Convert.ToInt32(reader["Lock"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, long ID)
        {
            string str = "";
            string[] myParams = new string[] { "@ID" };
            object[] myValues = new object[] { ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "INVENTORY_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ID = Convert.ToInt64(reader["ID"]);
                    this.m_Stock_Date = Convert.ToDateTime(reader["Stock_Date"]);
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_ProductName = Convert.ToString(reader["ProductName"]);
                    this.m_Customer_ID = Convert.ToString(reader["Customer_ID"]);
                    this.m_Currency_ID = Convert.ToString(reader["Currency_ID"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle(reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_Bacth = Convert.ToString(reader["Bacth"]);
                    this.m_Lock = Convert.ToInt32(reader["Lock"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(string Stock_ID, string Product_ID)
        {
            string str = "";
            string[] myParams = new string[] { "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { Stock_ID, Product_ID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("INVENTORY_Get_By_Stock", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_Stock_ID = Convert.ToString(reader["Stock_ID"]);
                    this.m_Product_ID = Convert.ToString(reader["Product_ID"]);
                    this.m_ProductName = Convert.ToString(reader["Product_Name"]);
                    this.m_Quantity = Convert.ToSingle(reader["Quantity"]);
                    this.m_ExchangeRate = Convert.ToSingle((reader["ExchangeRate"] == DBNull.Value) ? 1 : reader["ExchangeRate"]);
                    this.m_UnitPrice = Convert.ToSingle(reader["UnitPrice"]);
                    this.m_Amount = Convert.ToSingle(reader["Amount"]);
                    this.m_Bacth = Convert.ToString(reader["Batch"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetByDate(string Stock_ID, string Product_Id, string productName, DateTime dateTime)
        {
            string[] myParams = new string[] { "@StockID", "@Product_Id", "@Product_Name", "@DenNgay" };
            object[] myValues = new object[] { Stock_ID, "%" + Product_Id + "%", "%" + productName + "%", dateTime };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_GetList_Date", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_GetList");
        }

        public DataTable GetList(string Stock_ID, string Product_Id, string productName, bool Zero)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id", "@Product_Name", "@Zero" };
            object[] myValues = new object[] { Stock_ID, "%" + Product_Id + "%", "%" + productName + "%", Zero };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_GetFull", myParams, myValues);
        }

        public DataTable GetListDate(DateTime FromDate, DateTime ToDate, string CustomerId, string ProviderID, string OutStock, string InStock, string ProductId, string ProductName, string Id)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@CustomerID", "@ProviderID", "@OutStock", "@InStock", "@ProductId", "@ProductName", "@ID" };
            object[] myValues = new object[] { FromDate, ToDate, CustomerId, ProviderID, OutStock, InStock, "%" + ProductId + "%", "%" + ProductName + "%", "%" + Id + "%" };
            return helper.ExecuteDataTable("Search", myParams, myValues);
        }

        public DataTable GetListDateAll(DateTime FromDate, DateTime ToDate, string CustomerId, string ProviderID, string OutStock, string InStock, string ProductId, string ProductName, string Id)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@CustomerID", "@ProviderID", "@OutStock", "@InStock", "@ProductId", "@ProductName", "@ID" };
            object[] myValues = new object[] { FromDate, ToDate, CustomerId, ProviderID, OutStock, InStock, "%" + ProductId + "%", "%" + ProductName + "%", "%" + Id + "%" };
            return helper.ExecuteDataTable("SearchAll", myParams, myValues);
        }

        public double GetQuantityStock(string Stock_ID, string Product_ID)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@Stock_ID", "@Product_ID" };
            object[] myValues = new object[] { Stock_ID, Product_ID };
            return (double) helper.ExecuteScalar("INVENTORY_GetQuantityStock", myParams, myValues, 0);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { this.m_ID, this.m_Stock_Date, this.m_Stock_ID, this.m_Product_ID, this.m_ProductName, this.m_Customer_ID, this.m_Currency_ID, this.m_Quantity, this.m_ExchangeRate, this.m_UnitPrice, this.m_Amount, this.m_Bacth, this.m_Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { this.m_ID, this.m_Stock_Date, this.m_Stock_ID, this.m_Product_ID, this.m_ProductName, this.m_Customer_ID, this.m_Currency_ID, this.m_Quantity, this.m_ExchangeRate, this.m_UnitPrice, this.m_Amount, this.m_Bacth, this.m_Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_Insert", myParams, myValues);
        }

        public string Insert(long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { ID, Stock_Date, Stock_ID, Product_ID, ProductName, Customer_ID, Currency_ID, Quantity, ExchangeRate, UnitPrice, Amount, Bacth, Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { ID, Stock_Date, Stock_ID, Product_ID, ProductName, Customer_ID, Currency_ID, Quantity, ExchangeRate, UnitPrice, Amount, Bacth, Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "INVENTORY_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { ID, Stock_Date, Stock_ID, Product_ID, ProductName, Customer_ID, Currency_ID, Quantity, ExchangeRate, UnitPrice, Amount, Bacth, Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_Insert", myParams, myValues);
        }

        public DataTable InwardReportDate(DateTime FromDate, DateTime ToDate, string Stock, string Product)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@StockID", "@ProductID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock, Product };
            return helper.ExecuteDataTable("STOCK_INWARD_DETAIL_ReportDate", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("INVENTORY", "INVENTORYID", "");
        }

        public DataTable Order(string Product_ID, string productName, string stockId)
        {
            string[] myParams = new string[] { "@Product_ID", "@Product_Name", "@Stock_ID" };
            object[] myValues = new object[] { "%" + Product_ID + "%", "%" + productName + "%", stockId };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_ORDER", myParams, myValues);
        }

        public DataTable OutwardReportDate(DateTime FromDate, DateTime ToDate, string Stock, string Product)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@StockID", "@ProductID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock, Product };
            return helper.ExecuteDataTable("STOCK_OUTWARD_DETAIL_ReportDate", myParams, myValues);
        }

        public DataTable QuantityDate(DateTime vFrom, DateTime vTo, string Stock_Id, string Product_ID, string Product_Name)
        {
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Product_ID", "@Product_Name", "@Stock_ID" };
            object[] myValues = new object[] { vFrom, vTo, "%" + Product_ID + "%", "%" + Product_Name + "%", Stock_Id };
            SqlHelper helper = new SqlHelper();
            helper.Error += new SqlHelper.ErrorEventHander(this.DispError);
            return helper.ExecuteDataTable("INVENTORY_DETAIL_SUMMARY_ByDate", myParams, myValues);
        }

        public DataTable Search(string Product_ID, string productName, string StockID)
        {
            string[] myParams = new string[] { "@Product_ID", "@Product_Name", "@Stock_ID" };
            object[] myValues = new object[] { "%" + Product_ID + "%", "%" + productName + "%", StockID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_Search", myParams, myValues);
        }

        public DataTable SearchStock(string Product_ID, string productName, string stockId)
        {
            string[] myParams = new string[] { "@Product_ID", "@Product_Name", "@Stock_ID" };
            object[] myValues = new object[] { "%" + Product_ID + "%", "%" + productName + "%", stockId };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_Search_Stock", myParams, myValues);
        }

        public DataTable Summary(string Stock_ID, string Product_Id)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id" };
            object[] myValues = new object[] { Stock_ID, Product_Id };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_SUMMARYREPORT", myParams, myValues);
        }

        public DataTable SummaryBelower(string Stock_ID, string Product_Id)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id" };
            object[] myValues = new object[] { Stock_ID, Product_Id };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_SUMMARY_BELOWER_REPORT", myParams, myValues);
        }

        public DataTable SummaryLimit(DateTime vFrom, DateTime vTo, string Stock_Id, string Product_ID, string Product_Name)
        {
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@Product_ID", "@Product_Name", "@Stock_ID" };
            object[] myValues = new object[] { vFrom, vTo, "%" + Product_ID + "%", "%" + Product_Name + "%", Stock_Id };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("Report_Summary", myParams, myValues);
        }

        public DataTable SummaryOver(string Stock_ID, string Product_Id)
        {
            string[] myParams = new string[] { "@Stock_ID", "@Product_Id" };
            object[] myValues = new object[] { Stock_ID, Product_Id };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("INVENTORY_SUMMARYREPORT", myParams, myValues);
        }

        public DataTable TransferReportDate(DateTime FromDate, DateTime ToDate, string Stock, string Product)
        {
            SqlHelper helper = new SqlHelper();
            string[] myParams = new string[] { "@FromDate", "@ToDate", "@StockID", "@ProductID" };
            object[] myValues = new object[] { FromDate, ToDate, Stock, Product };
            return helper.ExecuteDataTable("STOCK_TRANSFER_DETAIL_ReportDate", myParams, myValues);
        }

        public string Update()
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { this.m_ID, this.m_Stock_Date, this.m_Stock_ID, this.m_Product_ID, this.m_ProductName, this.m_Customer_ID, this.m_Currency_ID, this.m_Quantity, this.m_ExchangeRate, this.m_UnitPrice, this.m_Amount, this.m_Bacth, this.m_Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_Update", myParams, myValues);
        }

        public string Update(long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { ID, Stock_Date, Stock_ID, Product_ID, ProductName, Customer_ID, Currency_ID, Quantity, ExchangeRate, UnitPrice, Amount, Bacth, Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("INVENTORY_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { ID, Stock_Date, Stock_ID, Product_ID, ProductName, Customer_ID, Currency_ID, Quantity, ExchangeRate, UnitPrice, Amount, Bacth, Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "INVENTORY_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, long ID, DateTime Stock_Date, string Stock_ID, string Product_ID, string ProductName, string Customer_ID, string Currency_ID, double Quantity, double ExchangeRate, double UnitPrice, double Amount, string Bacth, int Lock)
        {
            string[] myParams = new string[] { "@ID", "@Stock_Date", "@Stock_ID", "@Product_ID", "@ProductName", "@Customer_ID", "@Currency_ID", "@Quantity", "@ExchangeRate", "@UnitPrice", "@Amount", "@Bacth", "@Lock" };
            object[] myValues = new object[] { ID, Stock_Date, Stock_ID, Product_ID, ProductName, Customer_ID, Currency_ID, Quantity, ExchangeRate, UnitPrice, Amount, Bacth, Lock };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "INVENTORY_Update", myParams, myValues);
        }

        public double Amount
        {
            get
            {
                return this.m_Amount;
            }
            set
            {
                this.m_Amount = value;
            }
        }

        public string Bacth
        {
            get
            {
                return this.m_Bacth;
            }
            set
            {
                this.m_Bacth = value;
            }
        }

        public string Currency_ID
        {
            get
            {
                return this.m_Currency_ID;
            }
            set
            {
                this.m_Currency_ID = value;
            }
        }

        public string Customer_ID
        {
            get
            {
                return this.m_Customer_ID;
            }
            set
            {
                this.m_Customer_ID = value;
            }
        }

        public double ExchangeRate
        {
            get
            {
                return this.m_ExchangeRate;
            }
            set
            {
                this.m_ExchangeRate = value;
            }
        }

        public long ID
        {
            get
            {
                return this.m_ID;
            }
            set
            {
                this.m_ID = value;
            }
        }

        public int Lock
        {
            get
            {
                return this.m_Lock;
            }
            set
            {
                this.m_Lock = value;
            }
        }

        public string Product_ID
        {
            get
            {
                return this.m_Product_ID;
            }
            set
            {
                this.m_Product_ID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return this.m_ProductName;
            }
            set
            {
                this.m_ProductName = value;
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        public double Quantity
        {
            get
            {
                return this.m_Quantity;
            }
            set
            {
                this.m_Quantity = value;
            }
        }

        public DateTime Stock_Date
        {
            get
            {
                return this.m_Stock_Date;
            }
            set
            {
                this.m_Stock_Date = value;
            }
        }

        public string Stock_ID
        {
            get
            {
                return this.m_Stock_ID;
            }
            set
            {
                this.m_Stock_ID = value;
            }
        }

        public double UnitPrice
        {
            get
            {
                return this.m_UnitPrice;
            }
            set
            {
                this.m_UnitPrice = value;
            }
        }
    }
}

